package com.its.gym.exceptionController;


import com.its.domain.BaseResult;
import com.its.gym.exception.BusException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*
* 配置全局异常处理控制器类
* */
@ControllerAdvice
public class MyGlobalExceptionController {

    //声明异常处理方法
    @ExceptionHandler(value = {BusException.class})
    @ResponseBody
    public BaseResult busException(BusException busException){
        //输出异常信息
        busException.printStackTrace();
        //响应结果
        return new BaseResult(busException.getCode(),busException.getMessage(),null);
    }
}
